<?php

namespace Profiel\Model;

class Index {
    private $_gegevens = [];
    private $_boodschap = '';
    
    public function getPersoon() {
        $dbSql = "SELECT * FROM persoon WHERE id=:persoonid";
        try{
            $dbStmt = \Db::GET()->prepare($dbSql);
            $dbStmt->execute([':persoonid'=>$_SESSION['persoonid']]);
            if ($dbStmt->rowCount()==0) {
                return false;
            } else {
                $persoon = $dbStmt->fetch(\PDO::FETCH_ASSOC);
                return $persoon;
            }
            
        } catch (PDOException $ex) {

        }
    }
    
    public function getAdres() {
        $dbSql = "SELECT * FROM persoonadres WHERE idpersoon=:idpersoon";
        try{
            $dbStmt = \Db::GET()->prepare($dbSql);
            $dbStmt->execute([':idpersoon'=>$_SESSION['persoonid']]);            
            if ($dbStmt->rowCount()==0) {
                return [];
            } else {
                $adressenLijst = [];
                while($adres = $dbStmt->fetch(\PDO::FETCH_ASSOC)) {
                    array_push($adressenLijst,$adres);
                }                
                return $adressenLijst;
            }
            
        } catch (PDOException $ex) {

        }
    }
}
